
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <title>用户管理</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/cyUtil.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/cyEasyUi.js"></script>
    <link rel="stylesheet"
          href="${pageContext.request.contextPath}/js/jquery-easyui/themes/default/easyui.css"
          type="text/css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/js/jquery-easyui/themes/icon.css"
          type="text/css"/>

    <script type="text/javascript">
        $(function(){
            $("#user_manage_dataGrid").datagrid({
                fit : true,
                border : false,
                fitColumns : true,
                pagination : true,
                pagePosition : 'bottom',
                pageSize : 15,
                pageList : [ 10, 15, 20 ],
                idField : 'id',
                checkOnSelect : false,
                selectOnCheck : false,
                url : '${pageContext.request.contextPath}/user/userManageAction!load',
                columns : [[{
                    checkbox : true,
                    field : "id",
                    title : "编号",
                    width : 20,
                    sortable : true
                },{
                    field : "account",
                    title : "用户名",
                    width : 50,
                    resizable : true,
                    sortable : true
                },{
                    field : "name",
                    title : "昵称",
                    width : 50,
                    resizable : true
                },{
                    field : "realname",
                    title : "真实姓名",
                    width : 50,
                    resizable : true
                },{
                    field : "phone",
                    title : "电话号码",
                    width : 50,
                    resizable : true
                },{
                    field : "qq",
                    title : "QQ",
                    width : 50,
                    resizable : true
                },{
                    field : "birthdate",
                    title : "生日",
                    width : 50,
                    resizable : true
                },{
                    field : "email",
                    title : "电子邮件",
                    width : 50,
                    resizable : true
                },{
                    field : "homepage",
                    title : "主页",
                    width : 50,
                    resizable : true
                },{
                    field : "interests",
                    title : "兴趣爱好",
                    width : 50,
                    resizable : true
                },{
                    field : "sex",
                    title : "性别",
                    width : 50,
                    resizable : true
                },{
                    field : "creatime",
                    title : "创建时间",
                    width : 50,
                    resizable : true
                },{
                    field : "logintime",
                    title : "登陆时间",
                    width : 50,
                    resizable : true
                },{
                    title:"操作",
                    field:"action",
                    width:90,
                    formatter:function(value,row){
                        var str = "";
                        str += formatString("<button type='button' onclick=\"editFun('{0}')\">{1}</button>", row.id,"修改");
                        str += formatString("<button type='button' onclick=\"grantRoleFun('{0}')\">{1}</button>", row.id,"角色");
                        str += formatString("<button type='button' onclick=\"grantOrganizationFun('{0}')\">{1}</button>", row.id,"机构");
                        return str;
                    }
                }]],
                toolbar : [ {
                    text : '删除',
                    iconCls : 'icon-remove',
                    handler : function() {
                        deleteFun();
                    }
                }, '-',{
                    text : '增加',
                    iconCls : 'icon-add',
                    handler : function() {
                        addFun();
                    }
                }, '-' ]
            })
        });

        function searchFun(){
            $('#user_manage_dataGrid').datagrid('load', serializeObject($("#user_manage_searchForm")));
        }

        function cleanFun(){
            $('#user_manage_layout input[name=account]').val('');
            $('#user_manage_dataGrid').datagrid('load', {});
        }

        function addFun(){
            alert("还没写");
        }

        function editFun(id){
            console.info(id);
        }

        function deleteFun(){
            var rows = $("#user_manage_dataGrid").datagrid("getChecked");
            var ids = [];
            if(rows.length > 0){
                $.messager.confirm("确认","您是否要删除当前选中的条目?",function(r){
                    if(r){
                        $.each(rows,function(index){
                            ids.push(rows[index].id);
                        });

                        $.ajax({
                            url:"${pageContext.request.contextPath}/user/userManageAction!remove",
                            data:{ids : ids.join(",")},
                            dataType : "json",
                            success : function(obj) {
                                if (obj.success) {
                                    $("#user_manage_dataGrid").datagrid("load");
                                    $("#user_manage_dataGrid").datagrid("uncheckAll");
                                }
                                $.messager.show({
                                    title : "提示",
                                    msg: obj.msg
                                });
                            }
                        });
                    }
                });
            }
        }

        var grantRoleFun = function(id) {
            console.info(id);
        }

        var grantOrganizationFun = function(id){
            console.info(id);
        }
    </script>
</head>
<body>
    <div id="user_manage_layout" class="easyui-layout" data-options="fit:true">
          <div data-options="region:'north',border:false" style="margin-top: 10px; height: 30px;">
             <form id="user_manage_searchForm">
                 检索用户名:
                 <input type="text" name="account"/>
                 <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="searchFun();">搜索</a>
                 <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="cleanFun();">清空</a>
             </form>
          </div>
          <div data-options="region:'center',border:false">
              <table id="user_manage_dataGrid"></table>
          </div>
    </div>
</body>
</html>
